using System.Collections.Generic;
using Universe.OneC;

namespace Universe.OneC
{
    public class ServerInfo
    {
        private List<Cluster> _Clusters;
        private List<InfoBase> _InfoBases;
        private string _Name;
        private string _Password;
        private int _Port;
        private string _UserName;
        private int _Version;

        private ServerInfo()
        {
            this._Name = "";
            this._Port = 0x604;
            this._UserName = "";
            this._Password = "";
            this._InfoBases = new List<InfoBase>();
            this._Clusters = new List<Cluster>();
        }

        public ServerInfo(string name)
        {
            this._Name = "";
            this._Port = 0x604;
            this._UserName = "";
            this._Password = "";
            this._InfoBases = new List<InfoBase>();
            this._Clusters = new List<Cluster>();
            this._Name = name;
            this._Version = 0;
        }

        public ServerInfo(int version, string name) : this(name)
        {
            this._Version = version;
        }

        public ServerInfo(string name, int port) : this(name)
        {
            this._Port = port;
            this._Version = 1;
        }

        public ServerInfo(int version, string name, int port) : this(name, port)
        {
            this._Version = version;
        }

        public override string ToString()
        {
            return this._Name;
        }

        public string Address
        {
            get
            {
                if (this._Version != 0)
                {
                    return ("tcp://" + this._Name + ":" + this._Port.ToString());
                }
                return this._Name;
            }
        }

        public List<Cluster> Clusters
        {
            get
            {
                return this._Clusters;
            }
        }

        public List<InfoBase> InfoBases
        {
            get
            {
                return this._InfoBases;
            }
        }

        public string Name
        {
            get
            {
                return this._Name;
            }
        }

        public string Password
        {
            get
            {
                return this._Password;
            }
            set
            {
                this._Password = value;
            }
        }

        public int Port
        {
            get
            {
                return this._Port;
            }
        }

        public string UserName
        {
            get
            {
                return this._UserName;
            }
            set
            {
                this._UserName = value;
            }
        }

        public int Version
        {
            get
            {
                return this._Version;
            }
        }
    }
}